package com.juntuo.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.juntuo.Enums.ParkStatus;
import com.juntuo.entity.Park;
import com.juntuo.mapper.ParkMapper;
import com.juntuo.service.ParkService;
import com.juntuo.service.helper.CommonServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * 简介：片区 街道 泊位的服务
 * 作者：Jason (chenxj@hadlinks.com)
 * 时间：2018/3/17 16:22
 */
@Service
public class ParkServiceImpl extends CommonServiceImpl<Park> implements ParkService {
    @Autowired
    private ParkMapper parkMapper;


    @Override
    public List<Park> findAllPark() {
        return parkMapper.selectAll();
    }

    @Override
    public PageInfo<Map<String,Object>> findPagedPark(int pageNum, int pageSize, int areaId,int streetId, String number) {
        PageHelper.startPage(pageNum,pageSize);
        List<Map<String,Object>> parks=parkMapper.selectByParams(number,areaId,streetId);
        PageInfo pageInfo= new PageInfo(parks);
        return pageInfo;
    }

    @Override
    public void addPark(String number, int streetId) {
        Park park = new Park();
        park.setStreetId(streetId);
        park.setNumber(number);
        park.setStatus(ParkStatus.WAITING_FOR_BIND.getCode());
        park.setCreateTime(new Date());
        parkMapper.insert(park);
    }

//    @Override
//    public void deleteParkByArea(Area area) {
////        parkDao.remove(parkDao.query().is("area",area));
//    }
//
//    @Override
//    public void deleteParkByStreet(Street street) {
////        parkDao.remove(parkDao.query().is("street",street));
//    }
//
//    @Override
//    public void deletePark(String id) {
////        parkDao.remove(id);
//    }
}
